package com.adcc.test.gwtester;

import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;
import java.util.Set;

import org.eclipse.swt.internal.win32.PROCESS_INFORMATION;

public class Configuration {
	
	private final static String CONFIG_PATH = "./config/conf.properties";
	
	private static Configuration instance;
	
	private String username;
	
	private String password;
	
	private int activeModeACM;
	
	private int activeModeIBM;
	
	private Configuration(){
		
	}
	
	public static Configuration getInstance(){
		if(instance == null){
			instance = new Configuration();
		}
		return instance;
	}
	
	public void load() throws Exception{
		File file;
		FileInputStream fis = null;
		try{
			file = new File(CONFIG_PATH);
			fis = new FileInputStream(file);
			Properties pro = new Properties();
			pro.load(fis);
			username = pro.getProperty("username","admin");
			password = pro.getProperty("password","password");
			activeModeACM = Integer.parseInt(pro.getProperty("activeModeACM", "0"));
			activeModeIBM = Integer.parseInt(pro.getProperty("activeModeIBM", "0"));
		}catch(Exception ex){
			Log.error("load() error",ex);
			throw ex;
		}finally{
			if(fis != null){
				fis.close();
			}
		}
	}
	
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	
	public int getActiveModeACM() {
		return activeModeACM;
	}
	
	public void setActiveModeACM(int activeModeACM) {
		this.activeModeACM = activeModeACM;
	}
	
	public int getActiveModeIBM() {
		return activeModeIBM;
	}
	
	public void setActiveModeIBM(int activeModeIBM) {
		this.activeModeIBM = activeModeIBM;
	}
}
